Skip to content

Conversation

jeffreylovitz
Copy link
Contributor

@jeffreylovitz jeffreylovitz commented Sep 1, 2021

Since the Graph struct contains a mutex, misbehaviors can occur if this struct is copied by pass-by-value returns. GraphNew instantiates and returns a Graph value, but this is safe because no other copies of the object exist.

The DeepSource complaint can be simply avoided by returning the new Graph struct directly rather than assigning it to a local variable first.

@swilly22 swilly22 merged commit d223574 into master Sep 1, 2021
@swilly22 swilly22 deleted the mutex-passed-by-value branch September 1, 2021 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants